
import request from '@/utils/request'

// 执行代码
export function executeCode(data) {
  return request({
    url: '/unifiedmanagement/api/online-ide/execute',
    method: 'post',
    data: data
  })
}

// 获取支持的编程语言列表
export function getSupportedLanguages() {
  return request({
    url: '/unifiedmanagement/api/online-ide/languages',
    method: 'get'
  })
}

// 获取AI回复（非流式）
export function getAIResponse(data) {
  return request({
    url: '/unifiedmanagement/ai/qwen/chat',
    method: 'post',
    params: {
      message: data.question
    }
  })
}

// 获取AI回复（流式）
export function getAIResponseStream(question) {
  // 返回EventSource对象用于流式接收数据
  const url = `/unifiedmanagement/ai/qwen/chat/stream?message=${encodeURIComponent(question)}`;
  return new EventSource(url);
}